package com.patterns.prototype;

public class DeepSheepTest {
	public static void main(String[] args) throws Exception {
		
		DeepSheep s1 = new DeepSheep("Terry", "绵羊", new DeepColor("白色"));
		DeepSheep s2 = (DeepSheep) s1.clone();
		//Sheep [name=Terry, type=绵羊, color=Color [color=白色]]
		System.out.println(s1);
		//Sheep [name=Terry, type=绵羊, color=Color [color=白色]]
		System.out.println(s2);
		
		//深复制验证，修改新对象中的对象属性，原对象中的对象属性不变
		s2.getColor().setColor("红色");
		//Sheep [name=Terry, type=绵羊, color=Color [color=白色]]
		System.out.println(s1);
		//Sheep [name=Terry, type=绵羊, color=Color [color=红色]]
		System.out.println(s2);
	}
}
